home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / UTILITY / RSORT.ARJ / EXAMPLES.DOC next >
Text File  |  1991-09-17  |  34KB  |  754 lines

  1.  
  2.  
  3.   September 17, 1991           RPSORT Examples                       Page   i
  4.  
  5.                               Table of Contents
  6.                               -----------------
  7.  
  8.   Suggestion On How To Use This Document                                    1
  9.   General Rules For Entry Of Parameters                                     1
  10.   Cautionary Note On Specifying The Output File To RPSORT                   1
  11.  
  12.   Examples That Could Be Executed By The DOS SORT                           2
  13.     1. RPSORT As A Filter                                                   2
  14.     2. Sending Output To The Screen                                         2
  15.     3. Specifying A Sort Key                                                2
  16.     4. Reverse (Descending) Sort                                            2
  17.     5. Using Pipes With RPSORT.                                             2
  18.  
  19.   Examples Of General Interest                                            3-8
  20.     6. Using RPSORT Not As A Filter                                         3
  21.     7. Fixed Length Records                                                 3
  22.     8. Multiple Input Files                                                 3
  23.     9. ASCII (Case Sensitive) Sort                                          3
  24.    10. Reverse (Descending) Sort                                            3
  25.    11. Reverse ASCII Sort                                                   4
  26.    12. Specifying Key Length                                                4
  27.    13. Specifying Key Length But No Start Column                            4
  28.    14. Multiple Sort Keys                                                   4
  29.    15. Another Example Of Multiple Sort Keys                                4
  30.    16. Sort DIR Listing With Multiple Sort Keys                             5
  31.    17. Make ASCII Sequence The Default                                      5
  32.    18. Make Reversed (Descending) Sort The Default                          5
  33.    19. Make Both ASCII And Reversed The Default                             6
  34.    20. Delete Null Lines                                                    6
  35.    21. Delete Lines/Records With Duplicate Keys                             6
  36.    22. Delete Lines/Records If They Are Completely Identical                6
  37.    23. Specify Drive For Temporary Files                                    6
  38.    24. Ignore Ctrl-Z And Use The Entire File                                7
  39.    25. Suppress Copyright And Successful Completion Messages                7
  40.    26. Put Error Messages In A File                                         7
  41.    27. Suppress Copyright Message And Put Error Messages In A File          7
  42.    28. Tell RPSORT To Ignore Any Ctrl-Break From The Keyboard               7
  43.    29. Expanding Tabs In A File                                             8
  44.  
  45.   Examples Of Special Interest To Computer Programmers                   9-11
  46.    30. C Language String As Sort Key                                        9
  47.    31. Mixing C Language Strings And Regular Strings                        9
  48.    32. Turbo Pascal String As Sort Key                                      9
  49.    33. Mixing Turbo Pascal Strings And Regular Strings                      9
  50.    34. Make C Language Strings The Default                                 10
  51.    35. Make Turbo Pascal Strings The Default                               10
  52.    36. Signed Binary Integer As Sort Key                                   10
  53.    37. Turbo Pascal String And Signed Binary Integer                       10
  54.    38. Unsigned Binary Integer As Sort Key                                 11
  55.    39. 80x87 Floating Point Number As Sort Key                             11
  56.    40. BASICA & GWBASIC Floating Point Number As Sort Key                  11
  57.    41. Turbo Pascal Real Number As Sort Key                                11
  58.  
  59.   List Of Various Compiler And Interpreter Numeric Data Types              12
  60.  
  61.  
  62.  
  63.   September 17, 1991           RPSORT Examples                       Page   1
  64.  
  65.  
  66.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  67.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  68.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  69.  
  70.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  71.  
  72.  
  73.   Suggestion On How To Use This Document
  74.  
  75.     The syntax for RPSORT is simpler than the forbidding usage specification,
  76.     above, might suggest.  There are three kinds of parameters:
  77.  
  78.     . Filespecs. For the input to RPSORT you can have either a single
  79.       filespec or a list of filespecs separated by plus signs.  For the
  80.       output only a single filespec is allowed.
  81.  
  82.     . Switches.  These are a slash followed by a letter indicating the type
  83.       of switch.  Some switches also include a number, filespec or drive.
  84.  
  85.     . Sort key definitions.  These are a slash followed by a plus sign ("/+")
  86.       and one or more attributes which define a sort key.
  87.  
  88.     In this document, I start with the simplest examples and build up to
  89.     examples that include several parameters.  Eventually every type of
  90.     parameter that RPSORT supports appears at least once.
  91.  
  92.     Many of the parameters are only described once or twice when they first
  93.     appear in examples.  Though they may be used in subsequent examples they
  94.     will not be described there.  Therefore, I suggest that the best idea
  95.     would be to scan the examples in order rather than skipping around to
  96.     topics of interest.
  97.  
  98.  
  99.   General Rules For Entry Of Parameters
  100.  
  101.   . All parameters may be entered in upper or lower case as you choose.  As
  102.     far as RPSORT is concerned, there is no difference.
  103.  
  104.   . The parameters may be entered in any sequence except as noted in the
  105.     discussion of some RPSORT examples.
  106.  
  107.   . In the commands below, I separate the parameters with spaces for clarity.
  108.     RPSORT generally accepts spaces between parameters but does not require
  109.     them except as noted in the discussion of some RPSORT examples.
  110.  
  111.  
  112.   Cautionary Note On Specifying The Output File To RPSORT
  113.  
  114.   . If you specify a filespec, for the output, whose path and filename are
  115.     the same as that for an existing file, the latter will be replaced by the
  116.     output from RPSORT.  If this is what you want, fine, but if you don't
  117.     want to lose the existing file then use a different name for the output.
  118.  
  119.  
  120.  
  121.   September 17, 1991           RPSORT Examples                       Page   2
  122.  
  123.  
  124.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  125.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  126.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  127.  
  128.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  129.  
  130.  
  131.   Examples That Could Be Executed By The DOS SORT
  132.  
  133.     The first five examples are commands that could be executed by DOS SORT
  134.     but RPSORT does them much faster and can do them for much larger files.
  135.  
  136.  
  137.     1. RPSORT is here used as a filter which is the only option for the DOS
  138.        SORT.  No sort key is defined, so the sort key is the entire line.
  139.        The default for RPSORT and the only option for the DOS SORT is that:
  140.  
  141.        . The input is a text file consisting of lines each ending with a CRLF
  142.          (i.e. a carriage return and a line feed.)
  143.        . The sort key is case insensitive.  Lower case letters sort equal to
  144.          upper case letters and foreign letters, punctuation and currency
  145.          symbols sort equal to their American English equivalents.
  146.  
  147.            RPSORT  <MYINPUT.DAT  >C:\MYSORTED.DAT
  148.  
  149.  
  150.     2. No output file is specified, so output goes to the screen.  You must
  151.        specify an input file for RPSORT.  Unlike the DOS SORT, it doesn't
  152.        accept input data from the keyboard.
  153.  
  154.            RPSORT  <MYINPUT.DAT
  155.  
  156.  
  157.     3. The sort key starts at column 12 and consists of the rest of the line.
  158.        This is the only option for the DOS SORT and the default for RPSORT.
  159.        One sort key is listed which is all that the DOS SORT allows.
  160.  
  161.            RPSORT  /+12  <D:\MYDIR\INPUT.TXT  >D:\OTHERDIR\SORTED.DAT
  162.  
  163.  
  164.     4. The /R switch tells RPSORT to do a reverse (descending) sort.  The
  165.        sort key starts at column 23.
  166.  
  167.            RPSORT  /R  /+23  <DATA.TXT  >SORT.TXT
  168.  
  169.  
  170.     5. Sorts a DIR listing by the file extension (extension is at column 10)
  171.        and lists one page at a time.  The output of the DIR command is piped
  172.        to RPSORT the output from RPSORT is piped to the MORE command.  If you
  173.        sort the default directory, the listing might include two strange file
  174.        names.  These are temp files created by DOS to hold data being piped.
  175.  
  176.            DIR  C:\*.*  |  RPSORT  /+10  |  MORE
  177.  
  178.  
  179.  
  180.   September 17, 1991           RPSORT Examples                       Page   3
  181.  
  182.  
  183.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  184.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  185.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  186.  
  187.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  188.  
  189.  
  190.   Examples Of General Interest
  191.  
  192.  
  193.     6. RPSORT does not have to be used as filter.  The files can be specified
  194.        without redirection.  You must always enter the input filespec first
  195.        and the output filespec second.  The sort key starts at column 4 and
  196.        consists of the rest of the line.
  197.  
  198.            RPSORT  /+4  MYINPUT.TXT  D:\DATADIR\SORTOP.DAT
  199.  
  200.  
  201.     7. RPSORT can sort fixed length records.  The /F75 switch says that the
  202.        input consists of records each 75 bytes long.  It is not required that
  203.        the records end with a CRLF but if they do, the record length given by
  204.        the /F switch must include the two bytes for the CRLF.  The sort key
  205.        starts at column 13 and consists of the rest of the record.
  206.  
  207.            RPSORT  /F75  /+13  B:INPUT.DAT  SORTED.DAT
  208.  
  209.  
  210.     8. For the input, you can list muliple filespecs separated by plus signs.
  211.        No spaces are allowed between the input filespecs only plus signs.
  212.        RPSORT combines the input files and sorts them as one.  The combined
  213.        sorted output is then written to the single output file.
  214.  
  215.            RPSORT  INPUT1.DAT+C:\MYDIR\INPUT2.DAT+INPUT3.DAT  OUTPUT.DAT
  216.  
  217.        Note that wildcard characters (* or ?) are not allowed in any filename.
  218.  
  219.  
  220.     9. The sort key starts at column 7 of the 90 byte record.  This is an
  221.        ASCII (case sensitive) sort as indicated by the A in the sort key
  222.        definition.
  223.  
  224.        The sequence is per the ASCII value assigned to each character.  This
  225.        puts the digits 0 through 9 before any letters and puts all of the
  226.        upper case letters before any of the lower case letters.
  227.  
  228.            RPSORT  /F90  /+7A  DATA.DAT  SORT.DAT
  229.  
  230.  
  231.    10. The sort key starts at column 11 of the line.  It will be sorted in
  232.        the descending case insensitive sequence as indicated by the R in the
  233.        sort key definition.  This is also called a descending sort.
  234.  
  235.            RPSORT  /+11R  MYIP.DAT  B:MYSORT.DAT
  236.  
  237.  
  238.  
  239.   September 17, 1991           RPSORT Examples                       Page   4
  240.  
  241.  
  242.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  243.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  244.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  245.  
  246.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  247.  
  248.  
  249.   Examples Of General Interest (continued)
  250.  
  251.  
  252.    11. The sort key starts at column 6 of the 60 byte record.  It will be
  253.        sorted in the descending ASCII (case sensitive) sequence as indicated
  254.        by the A and R attributes in the sort key definition.
  255.  
  256.            RPSORT  /F60  /+6AR  IP1.DAT+IP2.DAT  OP.DAT
  257.  
  258.  
  259.    12. An ASCII sort key starts at position 11 of the line and is 7
  260.        characters long.  A colon followed by a number, in a sort key
  261.        definition, represents the length of the sort key.
  262.  
  263.            RPSORT  /+11:7A  DATA1.DOC+B:DATA2.DOC  SORTDATA.DOC
  264.  
  265.  
  266.    13. The case insensitive sort key starts at column 1, by default, because
  267.        the starting column is not given in the sort key definition.  The key
  268.        is 9 bytes long.
  269.  
  270.            RPSORT  /F80  /+:9  INPUT.DAT  OUTPUT.DAT
  271.  
  272.  
  273.    14. You can list as many sort keys definitions, as you like, provided they
  274.        fit within the command line (maximum of 127 bytes).  The first sort
  275.        key is 6 bytes starting at column 13, the second is an 8 byte ASCII
  276.        key at column 1 and the third a 4 byte key at column 19.
  277.  
  278.        A sort involves comparing two lines at a time in order to sequence
  279.        them correctly.  RPSORT compares two lines by comparing the sort keys
  280.        in the same order as their listing in the command line.
  281.  
  282.        The first unequal compare, if any, determines the sequence of the two
  283.        lines.  If all the sort keys are equal then the lines are sequenced
  284.        per their positions in the input file.
  285.  
  286.            RPSORT  /+13:6  /+:8A  /+19:4  DATA1.TXT+DATA2.TXT  SORT.TXT
  287.  
  288.  
  289.    15. Another example of multiple sort keys this time for a fixed length
  290.        record.  The first sort key uses the descending ASCII sequence, the
  291.        second uses the case insensitive sequence and the third uses the
  292.        descending case insensitive sequence.
  293.  
  294.            RPSORT  /F50  /+15:3AR  /+4:7  /+21:9R  INPUT.DAT  SORTEDIP.DAT
  295.  
  296.  
  297.  
  298.   August 24, 1991              RPSORT Examples                       Page   5
  299.  
  300.  
  301.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  302.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  303.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  304.  
  305.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  306.  
  307.  
  308.   Examples Of General Interest (continued)
  309.  
  310.  
  311.    16. Here RPSORT is used as a filter with the input coming from a DIR
  312.        command and the sorted output going to a MORE command which displays
  313.        the output one screen at a time. The effect of the sort keys is to
  314.        sort the directory entries by creation date (first by year then by
  315.        month and day) and by file name and extension within creation date.
  316.  
  317.            DIR  D:\*.*  |  RPSORT  /+30:2  /+24:5  /+:12  |  MORE
  318.  
  319.        If you are sorting the default directory, the listing might contain
  320.        two strange file names.  These are temporary files created by DOS to
  321.        hold the data being piped.
  322.  
  323.        If you have DOS 5.0 you don't a sort utility to produce a sorted
  324.        directory listing.  Instead you can use the new "/O" switch.  The
  325.        following command achieves a similar effect as the previous one except
  326.        that it sorts on both the creation date and time:
  327.  
  328.            DIR  D:\*.*   /P   /ODNE
  329.  
  330.  
  331.    17. The /A switch tells RPSORT that both sort keys, in the example, are to
  332.        be sorted according to the ASCII sequence.  The first key uses the
  333.        regular ASCII sequence while the second sort key uses the descending
  334.        ASCII sequence as indicated by the R attribute.
  335.  
  336.        If you specify /A, there is no way to change it for an individual
  337.        sort key.  If you want some sort keys to be ASCII and some to be case
  338.        insensitive, don't use /A but instead specify A in the appropriate
  339.        sort key definitions.
  340.  
  341.            RPSORT  /F120  /A  /+19:4  /+3:9R  MYDATA.DAT  SORTDATA.DAT
  342.  
  343.  
  344.    18. The /R switch tell RPSORT to do a descending (reverse) sort for all
  345.        the sort keys.  The first key uses the descending ASCII sequence, as
  346.        indicated by the A attribute, while the second sort key uses the
  347.        descending case insensitive sequence.
  348.  
  349.        If you specify /R, there is no way to change it for an individual sort
  350.        key.  If you want some sort keys to be descending and some not, don't
  351.        use /R but instead specify R for the appropriate sort key.
  352.  
  353.            RPSORT  /R  /+12:8A  /+:11  IP.TXT  OP.TXT
  354.  
  355.  
  356.  
  357.   September 17, 1991           RPSORT Examples                       Page   6
  358.  
  359.  
  360.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  361.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  362.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  363.  
  364.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  365.  
  366.  
  367.   Examples Of General Interest (continued)
  368.  
  369.  
  370.    19. Here both /A and /R are specified.  This means that all three sort
  371.        keys will use the descending ASCII sequence.
  372.  
  373.            RPSORT  /F90  /A  /R  /+1:7  /+11:5  /+8:3  DAT1.DAT  SORT.DAT
  374.  
  375.  
  376.    20. The /N switch tells RPSORT to delete all null lines from the sorted
  377.        output file.  A null line contains only CRLF (a carriage return and a
  378.        line feed) and nothing else.  Lines that are all spaces and thus look
  379.        like null lines when you list them will NOT be deleted.
  380.  
  381.            RPSORT  /N  /+3:9  /+1:2A  INPUT.DOC  SORTED.DOC
  382.  
  383.  
  384.    21. The /D switch tells RPSORT to delete from the sorted output all
  385.        records whose sort keys duplicate those in a previous record.  This
  386.        will delete records that are not identical to a previous record
  387.        because all that is required is that the sort keys be the same.
  388.  
  389.            RPSORT  /F100  /D  /+14:7  /+4:10R  DATA.DAT  SORTED.DAT
  390.  
  391.  
  392.    22. If you want to delete lines/records only if they are identical to a
  393.        previous line/record, tack on /+A as the final sort key.  Since this
  394.        uses the entire line as an ASCII key, it means that the only time all
  395.        keys will be equal is when the lines are identical.
  396.  
  397.            RPSORT  /D  /+14:7  /+4:10R  /+A  DATA.TXT  SORTED.TXT
  398.  
  399.  
  400.    23. The /T switch tells RPSORT where to put any temporary files, it may
  401.        require.  In this case, /TC says to put them on the C drive.
  402.  
  403.        If the input file is small enough to fit into the available memory, it
  404.        is sorted in one pass and temporary files are not required.  Else,
  405.        RPSORT reads and sorts the file a chunk at a time and writes the
  406.        sorted chunks to a temporary file.  Then RPSORT does one or more merge
  407.        phases to combine the chunks into a single sorted output file.
  408.  
  409.        If the /T switch is not specified, RPSORT puts any temporary files on
  410.        the default drive.
  411.  
  412.            RPSORT  /TC  /+9:12A  /+23:11R  BIGINPUT.DAT  BIGSORT.DAT
  413.  
  414.  
  415.  
  416.   September 17, 1991           RPSORT Examples                       Page   7
  417.  
  418.  
  419.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  420.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  421.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  422.  
  423.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  424.  
  425.  
  426.   Examples Of General Interest (continued)
  427.  
  428.  
  429.    24. The /Z switch tells RPSORT to ignore any Ctrl-Zs in a text file and to
  430.        use the entire file.  Normally RPSORT, like DOS, stops reading when it
  431.        finds a Ctrl-Z in an input file.  This is usually O.K. since the
  432.        Ctrl-Z, if present, normally follows the last byte of actual data.
  433.  
  434.        However, if Ctrl-Zs appear in the middle of a text file then you must
  435.        use /Z to get RPSORT to sort the entire file.
  436.  
  437.            RPSORT  /Z  /A  /+1:5R  /+11:3  DOWNLOAD.DAT  SORTED.DAT
  438.  
  439.  
  440.    25. The /Q switch suppresses the display of the copyright message at the
  441.        beginning and the successful completion message at the end.  Error
  442.        messages, if any, will still be displayed.  This switch must be the
  443.        first parameter on the command line.
  444.  
  445.            RPSORT  /Q  /F40  /+12:3A  /17:4R  INPUT.DAT  OUTPUT.DAT
  446.  
  447.  
  448.    26. The /E switch, in this example, tells RPSORT to create the file
  449.        MYERRORS.TXT and to direct any error or successful completion
  450.        messages to that file.  Except for the /Q switch, no other parameter
  451.        should precede this switch in the command line.
  452.  
  453.        Since the /Q switch was not specified in this example, the copyright
  454.        message will still appear on the screen.  Any error or successful
  455.        completion messages, if appropriate, will be sent to MYERRORS.TXT.
  456.  
  457.            RPSORT  /EMYERRORS.TXT  /2:9AR  DATA.TXT  SORTED.TXT
  458.  
  459.  
  460.    27. This example suppresses copyright and successful completion messages
  461.        and sends any error messages to the file SORTERR.DAT.
  462.  
  463.            RPSORT  /Q  /ESORTERR.DAT  /2:9AR  DATA.TXT  SORTED.TXT
  464.  
  465.  
  466.    28. Normally, RPSORT responds promptly to a Ctrl-Break from the keyboard
  467.        and lets you terminate the sort.  The /B switch, however, tells RPSORT
  468.        to ignore Ctrl-Break and to continue with the sort until it is done.
  469.  
  470.            RPSORT  /B   /4:13R   IP.DAT   OP.DAT
  471.  
  472.  
  473.  
  474.   September 17, 1991           RPSORT Examples                       Page   8
  475.  
  476.  
  477.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  478.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  479.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  480.  
  481.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  482.  
  483.  
  484.   Examples Of General Interest (continued)
  485.  
  486.  
  487.    29. If your input file contains tabs  and they need to be expanded to the
  488.        proper number of spaces for your sort keys to line up properly, then
  489.        RPSORT will not sort it correctly because RPSORT does not expand the
  490.        tabs. As a convenience, for those who face this problem, I have
  491.        included a program called RPTAB in this package.  It reads your file
  492.        and produces an output file that is the same except that the tabs have
  493.        been expanded.  The syntax is:
  494.  
  495.            RPTAB  input-filespec  output-filespec  [tabstop...]
  496.  
  497.        The parameters must be given in the indicated sequence.  Specifying
  498.        tab stops is optional.  If you specify none, the default tab stops are
  499.        at positions 1, 9, 17, 25, 33... and so on at intervals of eight
  500.        columns.  If you do specify tab stops they must be a sequence of
  501.        integers each greater than the preceding one.  The first tab stop is
  502.        always at column 1 and you need not specify it.  RPTAB follows the
  503.        rule that the interval between the last two specified tab stops
  504.        implies subsequent tab stops at the same interval.
  505.  
  506.        The following command expands tabs to the default tab stops:
  507.  
  508.            RPTAB   MYTABS.DAT   MYSPACES.DAT
  509.  
  510.        The following command:
  511.  
  512.            RPTAB   MYTABS.DAT   MYSPACES.DAT   6  15  27
  513.  
  514.        tells RPTAB that the tab stops are at positions 1, 6, 15, 27, 39, 51...
  515.        etc.  The interval of 12 between 15 and 27 is propagated to subsequent
  516.        tab stops.
  517.  
  518.        After creating MYSPACES.DAT as in the above examples, you could then
  519.        use RPSORT to sort it in the usual way.
  520.  
  521.  
  522.  
  523.  
  524.   September 17, 1991           RPSORT Examples                       Page   9
  525.  
  526.  
  527.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  528.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  529.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  530.  
  531.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  532.  
  533.  
  534.   RPSORT Examples Of Special Interest To Computer Programmers
  535.  
  536.  
  537.    30. The attribute C in a sort key definition says that the key is a C
  538.        language string.  This means that a binary zero, if present,
  539.        terminates the string.  Specify a key length equal to the maximum
  540.        length for the string.  For example, if you define "char mystr[7]" in
  541.        your C program then you should specify a key length of 7 to RPSORT.
  542.  
  543.        In this example, the first sort key is a C style string at column 1
  544.        whose maximum length is 7.  The second key is a C style string at
  545.        column 25 with maximum length 5.
  546.  
  547.            RPSORT  /F95  /+:7ACR  /+25:5C  CSTRING.DAT  SORTCSTR.DAT
  548.  
  549.  
  550.    31. RPSORT allows some of your sortkeys to be C style strings and some to
  551.        be regular character strings as in this example.
  552.  
  553.            RPSORT  /F80  /+13:12C  /+5:5  DATA.DAT  SORT.DAT
  554.  
  555.  
  556.    32. The attribute P in a sort key definition says that the key is a Turbo
  557.        Pascal string.  This means that the first byte of the key is a binary
  558.        integer representing the length of the actual string.
  559.  
  560.        You should specify a key length equal to one plus the maximum possible
  561.        length for the string.  For example, if you define "string[9] in your
  562.        Pascal program then you should specify a key length of 10 to RPSORT.
  563.        The one extra allows for the length byte.  Pascal strings are only
  564.        allowed as sort keys in fixed length records.
  565.  
  566.        In this example, the first sort key is a Pascal style string at column
  567.        3 whose maximum length is 9 (one less than the length of the key.  It
  568.        is to be sorted per the descending ASCII sequence.  The second key is
  569.        a Pascal style string at column 12 with a maximum length of 8.  It is
  570.        to be sorted per the case insensitive sequence.
  571.  
  572.            RPSORT  /F70  /+3:10APR  /+12:9P  PSTRING.DAT SORTPSTR.DAT
  573.  
  574.  
  575.    33. RPSORT allows some of your sortkeys be Pascal style strings and some
  576.        to be regular character strings as in this example.
  577.  
  578.            RPSORT  /F60  /+9:10  /+1:8P  PASCAL.DAT SORT.DAT
  579.  
  580.  
  581.  
  582.   September 17, 1991           RPSORT Examples                       Page  10
  583.  
  584.  
  585.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  586.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  587.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  588.  
  589.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  590.  
  591.  
  592.   RPSORT Examples Of Special Interest To Computer Programmers (continued)
  593.  
  594.  
  595.    34. The /C switch tells RPSORT that all your character string sort keys
  596.        are to be treated as C style strings.  If you specify /C, you can't
  597.        over-ride it for an individual sort key.  If you want some string keys
  598.        to be C style strings and some not, don't use /C.  Instead, specify C
  599.        in the appropriate sort key definitions.
  600.  
  601.            RPSORT  /F67  /C  /+3:9A  /+23:7  DATA.DAT  SORT.DAT
  602.  
  603.  
  604.    35. The /P switch tells RPSORT that all your character string sort keys
  605.        are to be treated as Pascal style strings.  If you specify /P, you
  606.        can't over-ride it for an individual sort key.  If you want some
  607.        string keys to be Pascal strings and some not, don't use /P but
  608.        instead specify P in the appropriate sort key definitions.
  609.  
  610.        Note that /C and /P are mutually exclusive.
  611.  
  612.            RPSORT  /F98  /P  /+23:11  /+12:67A  DATA.DAT  SORT.DAT
  613.  
  614.  
  615.    The remaining examples include sort keys which are binary numbers of some
  616.    type.  The table on page 12 lists the appropriate type and length
  617.    attributes for the binary number formats defined in several popular
  618.    compilers and interpreters.  Binary number sort keys are only allowed in
  619.    fixed length records.
  620.  
  621.  
  622.    36. The I attribute tells RPSORT that the first sort key, in this example,
  623.        is a signed binary integer.  RPSORT supports binary integers of any
  624.        length.  In this case the length of 8 would be appropriate for number
  625.        of the "comp" type in Turbo Pascal.
  626.  
  627.            RPSORT  /F112  /+12:8I  /+1:9P  INTEGER.DAT  SORTINT.DAT
  628.  
  629.  
  630.    37. This example produces the exact same result as the previous one.
  631.        Note that instead of using the P attribute in the second sort key
  632.        definition, I used the /P switch.  The important point is that while
  633.        the /P switch would apply to all character string keys it does not
  634.        apply to the first sort key because that is defined as a binary number
  635.        sort key.
  636.  
  637.            RPSORT  /F112  /P  /+12:8I  /+1:9  INTEGER.DAT  SORTINT.DAT
  638.  
  639.  
  640.  
  641.   September 17, 1991           RPSORT Examples                       Page  11
  642.  
  643.  
  644.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  645.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  646.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  647.  
  648.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  649.  
  650.  
  651.   RPSORT Examples Of Special Interest To Computer Programmers (continued)
  652.  
  653.  
  654.    38. The U attribute tells RPSORT that the second sort key is an unsigned
  655.        binary integer of length 2.  RPSORT supports binary integers of any
  656.        length.  In this case the length of 2 would be appropriate for an
  657.        "unsigned int" in Turbo C.
  658.  
  659.            RPSORT  /F97  /+2:11C  /+12:2U  UNSIGNED.DAT  SORT.DAT
  660.  
  661.  
  662.    39. The F attribute tells RPSORT that the first sort key, in this example,
  663.        is an 80x87 floating point number.  RPSORT supports three different
  664.        precisions of these numbers.  The table below gives the lengths for
  665.        each precision and the names assigned to them by Intel and by three
  666.        popular compilers.
  667.  
  668.           Length    Intel         QuickBasic    Turbo Pascal    Turbo C
  669.           ------    ----------    ----------    ------------    -------
  670.              4      short real    single        single          float
  671.              8      long  real    double        double          double
  672.             10      temp  real    N/A           extended        long double
  673.  
  674.        In this example the length of 8 would be appropriate for a sort key of
  675.        type double in any of the three compilers listed above.
  676.  
  677.            RPSORT  /F125  /+:8F  /+13:4  FLOAT.DAT  SORT.DAT
  678.  
  679.  
  680.    40. The M attribute tells RPSORT that the second sort key is a floating
  681.        point number of the type supported by BASICA, GWBASIC and older
  682.        versions of QuickBASIC (v3.0 and earlier).  RPSORT supports the 4 byte
  683.        single precision and the 8 byte double precision formats.
  684.  
  685.            RPSORT  /F92  /+13:8C  /+2:4M  BASICA.DAT  SORT.DAT
  686.  
  687.    41. The T attribute tells RPSORT that the first sort key is a Turbo Pascal
  688.        type "real" number.  This was the only floating point type in Turbo
  689.        Pascal versions 1.0 through 3.0.  It is still supported in version 6.0
  690.        but Turbo Pascal has now added the 80x87 floating point types (see
  691.        example 39 above and the table on page 12).
  692.  
  693.        I did not specify any length attribute because the length for this
  694.        type is always 6.  If you do specify a length, it must be 6.
  695.  
  696.            RPSORT  /F87  /+10T  /+3:7P  PASCAL.DAT  SORT.DAT
  697.  
  698.  
  699.  
  700.   September 17, 1991           RPSORT Examples                       Page  12
  701.  
  702.  
  703.   The following table lists the type and length attributes for the binary
  704.   numeric types available in a few programming language compilers and
  705.   interpreters.
  706.  
  707.  
  708.   Compiler Or Interpreter       Number Type  Type Attribute  Length Attribute
  709.   -----------------------       -----------  --------------  ----------------
  710.   Microsoft QuickBASIC          Integer             I                2
  711.    v4.0 and later &             Long                I                4
  712.   Microsoft QBASIC              Single              F                4
  713.                                 Double              F                8
  714.  
  715.   Microsoft QuickBASIC          Integer             I                2
  716.    v3.0, 8087                   Single              F                4
  717.                                 Double              F                8
  718.  
  719.   IBM BASICA &                  Integer             I                2
  720.   Microsoft GWBASIC &           Single              M                4
  721.   Microsoft QuickBASIC          Double              M                8
  722.    v1.0, v2.0 and v3.0 non-8087
  723.  
  724.   Turbo Pascal                  Shortint            I                1
  725.    v4.0 and later               Integer             I                2
  726.                                 Longint             I                4
  727.                                 Byte                U                1
  728.                                 Word                U                2
  729.                                 Real                T                6
  730.                                 Single              F                4
  731.                                 Double              F                8
  732.                                 Extended            F               10
  733.                                 Comp                I                8
  734.  
  735.   Turbo Pascal                  Integer             I                2
  736.    v3.0 8087                    Byte                U                1
  737.                                 Real                F                8
  738.  
  739.   Turbo Pascal                  Integer             I                2
  740.    v1.0, v2.0 and v3.0 non-8087 Byte                U                1
  741.                                 Real                T                6
  742.  
  743.   Borland/Turbo C               signed char         I                1
  744.                                 unsigned int        U                2
  745.                                 short int           I                2
  746.                                 int                 I                2
  747.                                 unsigned long       U                4
  748.                                 long                I                4
  749.                                 float               F                4
  750.                                 double              F                8
  751.                                 long double         F               10
  752.  
  753.  
  754.